import java.util.*;
public class Main1 {
    public int appendCharacters(String s, String t) {
        int a= s.length();
        int b= t.length();
        int j=0;
        for(int i=0;i<a;i++){
            if(s.charAt(i)==t.charAt(j)){
                j++;
                if(j>b){
                    return 0;
                }
            }
        }
        System.out.println(j);
        return b-j;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = new String();
        String t = new String();
        s=sc.nextLine();
        System.out.println(s);
        t = sc.nextLine();
        Main1 m2 = new Main1();
        System.out.println(m2.appendCharacters(s,t));
    }
}
